<template>
  <div class="box">
    <div class="img">
      <img src="../assets/1.jpg" alt="" />
    </div>
    <ul>
      <!-- 给添加点击事件 -->
      <li
        v-for="(item, index) in ull"
        :key="index"
        @click="dianji(index)"
        :class="{ active: dian == index }"
      >
        {{ item.text }}
      </li>
      <li class="pao">即将开抢</li>
    </ul>
    <div class="list">
      <div class="one" v-for="(item, index) in arr" :key="index">
        <div class="tu">
          <img :src="item.picture" alt="" />
        </div>
        <div class="right">
          <p class="name">{{ item.promotion_info }}</p>
          <h3 class="h2">{{ item.name }}</h3>
          <div class="xia">
            <div class="zuo">
              <p class="p1">爆爆团价</p>
              <p>￥{{ item.min_price }}</p>
              <p>已售{{ item.month_saled }}</p>
            </div>
            <div class="you">
              <span @click="changeStatu(item)">{{
                item.tag != 1 ? "马上抢" : "已抢"
              }}</span>
              <p>{{ item.month_saled_content }}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { tuan_list } from "../api";
export default {
  data() {
    return {
      dian: 0,
      arr: null,
      ull: [{ text: "正在抢购" }, { text: "上新预告" }],
      obj1: [],
    };
  },
  methods: {
    dianji(index) {
      this.dian = index;
      if (this.ull[index].text == "正在抢购") {
        tuan_list({ status: 0 }).then((res) => {
          this.arr = res.data.list;
          console.log(this.arr);
        });
      } else {
        tuan_list({ status: 1 }).then((res) => {
          this.arr = res.data.list;
        });
      }
    },
    changeStatu(item) {
      if (item.tag) {
        item.tag = 1;
      }
    },
  },
  mounted() {
    tuan_list({ status: 1 }).then((res) => {
      this.arr = res.data.list;
    });
  },
};
</script>

<style>
.box .img img {
  width: 100%;
  height: 100%;
  display: block;
}
ul {
  margin-top: -80px;
  padding: 10px;
  display: flex;
  position: relative;
}
ul li {
  color: white;
  padding: 10px 5px;
  margin: 20px;
}
ul .active {
  border-bottom: 2px solid white;
}
ul .pao {
  width: 50px;
  height: 8px;
  font-size: 12px;
  background: white;
  color: red;
  border-radius: 30px;
  text-align: center;
  line-height: 8px;
  position: absolute;
  top: -10px;
  left: 130px;
}
.list {
  height: 450px;
  overflow: auto;
}
.one {
  display: flex;
  margin: 10px 15px;
  padding: 10px;
  height: 150px;
  border-radius: 10px;
}
.one .tu {
  width: 150px;
  height: 150px;
  border-radius: 10px;
}
.one .tu img {
  width: 150px;
  height: 150px;
  border-radius: 10px;
}
.right {
  margin-left: 20px;
}
.right .name {
  height: 20px;
}
.right > p {
  font-size: 14px;
  color: rgb(73, 73, 73);
  margin-bottom: 5px;
}
.right .xia {
  margin-top: 10px;
  display: flex;
}
.right .xia .zuo p {
  font-size: 14px;
  color: red;
  margin-top: 5px;
}
.right .xia .zuo {
  margin-right: 50px;
}

.right .xia .you span {
  display: inline-block;
  margin: 5px 0;
  padding: 8px 15px;
  border-radius: 20px;
  background: red;
  color: white;
}
.right .xia .you p {
  font-size: 14px;
  color: red;
  margin-left: 5px;
}
</style>